import * as React from "react";
import {OrderModel} from "../../model/OrderModel";


export interface OrderDefaultProps {
    item: OrderModel,
    onChange: Function
}

export interface State {

}

export default class OrderItem extends React.Component<OrderDefaultProps, State> {
    //默认属性
    static readonly defaultProps: OrderDefaultProps = {
        item: null,
        onChange: null
    };

    constructor(props: OrderDefaultProps) {
        super(props);
        //默认状态
        this.state = {};
    }

    //组件挂载后回调
    componentDidMount() {
        document.title = "";
        // 我的订单中默认订单的效果组件
    }

    render() {
        return <div className="content-item">
            <div className="weui-cells">
                <a className="weui-cell weui-cell_access" href="javascript:;">
                    <div className=" weui-cell__bd weui-cell__bd2">
                        <p>订单号：{this.props.item.ordersn}</p>
                    </div>
                    <div className="weui-cell__ft" onClick={() => {
                        this.props.onChange();
                        // location.hash = `/order-detail/${this.props.item.id}`
                    }}>查看订单
                    </div>
                </a>
                <div className="weui-cell">
                    <div className="weui-cell__bd">
                        <p>待确认订单 {this.props.item.ogoods.length} </p>
                    </div>
                    <div className="weui-cell__ft">总金额： {this.props.item.price}元</div>
                </div>
                <div className="weui-cell">
                    <div className="weui-cell__bd">
                        <p>{this.props.item.createtime}</p>
                    </div>
                    <div className="weui-cell__ft">人工收款</div>
                </div>
            </div>
        </div>
    }
}
